/*
 * @Author: zqg
 * @Date: 2021-02-20 23:55:43
 * @LastEditors: zqg
 * @LastEditTime: 2021-02-22 09:15:49
 * @Description: file content
 */
import { parseTimeToYMDHMS } from '@/utils/index'
/**
 * @description: 获取考勤分类表格配置
 * @param {string} 考勤类型
 * @return {*}
 */
export function getAttendanceTableColumn(type) {
  switch (type) {
    case 'vacate':
      return [
        { name: '请假时间', value: 'startTime', type: 'text' },
        { name: '请假类型', value: 'attendanceType', type: 'text' },
        {
          name: '请假周期',
          type: 'render',
          render: row => {
            return `${row.startTime} 至 ${row.endTime}`
          }
        },
        { name: '请假天数', value: 'dayNum', type: 'text' },
        { name: '备注', value: 'remark', type: 'text' }
      ]
    case 'late':
      return [
        {
          name: '迟到日期',
          type: 'render',
          render: row => {
            return parseTimeToYMDHMS(row.startTime, 'YYYY-MM-DD')
          }
        },
        {
          name: '迟到时间',
          value: 'startTime',
          type: 'render',
          render: row => {
            return row.startTime
          }
        },
        { name: '备注', value: 'remark', type: 'text' }
      ]
    case 'noWork':
      return [
        { name: '录入时间', value: 'startTime', type: 'text' },
        {
          name: '旷工周期', type: 'render', render: row => {
            return `${row.startTime} 至 ${row.endTime}`
          }
        },
        { name: '旷工天数', value: 'dayNum', type: 'text' },
        { name: '备注', value: 'remark', type: 'text' }
      ]
    case 'forgetClockIn':
      return [
        { name: '忘打卡日期', value: 'startTime', type: 'text' },
        { name: '备注', value: 'remark', type: 'text' }
      ]
    case 'leaveEarly':
      return [
        {
          name: '早退日期',
          type: 'render',
          render: row => {
            return parseTimeToYMDHMS(row.startTime, 'YYYY-MM-DD')
          }
        },
        {
          name: '早退时间',
          value: 'startTime',
          type: 'render',
          render: row => {
            return row.startTime
          }
        },
        { name: '备注', value: 'remark', type: 'text' }
      ]
    case 'workOvertime':
      return [
        { name: '加班日期', value: 'startTime', type: 'text' },
        { name: '下班时间', value: 'endTime', type: 'text' },
        { name: '加班小时', value: 'dayNum', type: 'text' },
        { name: '备注', value: 'remark', type: 'text' }
      ]
    default:
      return []
  }
}
/**
 * @description: 新增考勤的表单展示信息配置
 * @param {string} type
 * @return {Object}
 */
export function addAttendanceFromConfig(type) {
  switch (type) {
    case 'vacate':
      return {
        holidayType: {
          isShow: true,
          labalText: '假期类型'
        },
        beginTime: {
          isShow: true,
          labalText: '请假日期'
        },
        endTime: {
          isShow: true,
          labalText: '结束日期'
        },
        howLong: {
          isShow: true,
          labalText: '请假天数'
        }
      }
    case 'late':
      return {
        holidayType: {
          isShow: false,
          labalText: ''
        },
        beginTime: {
          isShow: true,
          labalText: '迟到时间'
        },
        endTime: {
          isShow: false,
          labalText: ''
        },
        howLong: {
          isShow: false,
          labalText: ''
        }
      }
    case 'noWork':
      return {
        holidayType: {
          isShow: false,
          labalText: ''
        },
        beginTime: {
          isShow: true,
          labalText: '旷工日期'
        },
        endTime: {
          isShow: true,
          labalText: '结束日期'
        },
        howLong: {
          isShow: true,
          labalText: '旷工天数'
        }
      }
    case 'forgetClockIn':
      return {
        holidayType: {
          isShow: false,
          labalText: ''
        },
        beginTime: {
          isShow: true,
          labalText: '忘打卡日期'
        },
        endTime: {
          isShow: false,
          labalText: ''
        },
        howLong: {
          isShow: false,
          labalText: ''
        }
      }
    case 'leaveEarly':
      return {
        holidayType: {
          isShow: false,
          labalText: ''
        },
        beginTime: {
          isShow: true,
          labalText: '早退时间'
        },
        endTime: {
          isShow: false,
          labalText: ''
        },
        howLong: {
          isShow: false,
          labalText: ''
        }
      }
    case 'workOvertime':
      return {
        holidayType: {
          isShow: false,
          labalText: ''
        },
        beginTime: {
          isShow: true,
          labalText: '加班日期'
        },
        endTime: {
          isShow: true,
          labalText: '下班时间'
        },
        howLong: {
          isShow: true,
          labalText: '加班小时'
        }
      }
    default:
      return []
  }
}
